<template>
  <el-form
      :model="basicTypeForm"
      label-width="120px"
      size="small">
    <el-row>
      <el-col :span="20">
        <el-form-item label="分类名称：">
          <el-input disabled v-model="basicTypeForm.categoryName"></el-input>
        </el-form-item>
      </el-col>
    </el-row>

    <el-row>
      <el-col :span="20">
        <el-form-item label="英文名称：">
          <el-input v-model="basicTypeForm.name"></el-input>
        </el-form-item>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="20">
        <el-form-item label="显示名称：">
          <el-input v-model="basicTypeForm.text"></el-input>
        </el-form-item>
      </el-col>
    </el-row>

    <el-row>
      <el-col :span="20">
        <el-form-item label="存储类型：">
          <el-select v-model="basicTypeForm.jdbcTypeCode" placeholder="请选择" clearable>
            <el-option
                v-for="item in formProps.jdbcTypeArray"
                :key="item.code"
                :label="item.name"
                :value="item.code">
            </el-option>
          </el-select>
        </el-form-item>
      </el-col>
    </el-row>

    <el-row>
      <el-col :span="20">
        <el-form-item label="描述：">
          <el-input v-model="basicTypeForm.description"></el-input>
        </el-form-item>
      </el-col>
    </el-row>
  </el-form>
</template>

<script>

import {$BasicTypeApi} from "@/network/feature/BasicTypeApi";

export default {
  name: "BasicTypeForm",
  props: {
    formProps: {
      type: Object
    }
  },
  data() {
    return {
      basicTypeForm: {
        categoryId: '',
        categoryName: '',
        name: '',
        text: '',
        jdbcTypeCode: "",
        description: '',
      }
    }
  },

  methods: {

    takeFormData() {
      return {
        id: this.basicTypeForm.id,
        categoryId: this.basicTypeForm.categoryId,
        name: this.basicTypeForm.name,
        text: this.basicTypeForm.text,
        jdbcTypeCode: this.basicTypeForm.jdbcTypeCode,
        description: this.basicTypeForm.description
      };
    },

    initFormData() {
      this.basicTypeForm.categoryId = this.formProps.categoryId;
      this.basicTypeForm.categoryName = this.formProps.categoryName;
    },

    // 清空表单数据
    clearFormData() {
      this.basicTypeForm.categoryId = "";
      this.basicTypeForm.categoryName = "";
      this.basicTypeForm.name = "";
      this.basicTypeForm.text = "";
      this.basicTypeForm.description = "";
    },

    async formSubmit() {
      // debugger
      console.log(this.basicTypeForm);
      console.log(this.formProps);
      let oper = this.formProps.tableOper;
      if (oper === "add") {
        let res = await $BasicTypeApi.createBasicType({...this.basicTypeForm})
        console.log(res);
      }
    }
  },

  created() {
    this.initFormData();
  }

}
</script>

<style scoped>

</style>